package com.itheima.xml;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.util.List;

public class Test {
    public static void main(String[] args) throws DocumentException {
        SAXReader saxReader = new SAXReader();

        Document document = saxReader.read("D:/code/javase_day11-homework/src/books.xml");

        Element root = document.getRootElement();
//        System.out.println(root.getName());

        List<Element> books = root.elements();
        for (Element book : books) {
            System.out.println("-----------------------------");
            System.out.println("书名：" + book.elementText("title"));
            System.out.println("出版日期：" + book.elementText("press"));
            System.out.println("发布时间：" + book.elementText("publicationdate"));
            System.out.println("价格：" + book.elementText("price"));
        }
    }
}
